/**
 * 
 */
package org.lightcommons.orm.hibernate;

import java.util.List;
import java.util.Properties;

import org.hibernate.ConnectionReleaseMode;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * @author gl
 * @since Jun 16, 2008
 */
public class HibernateUtils {
	
	public static SessionFactory buildSessionFactory(List<Class<?>> annotatedClasses,Properties properties){
		AnnotationConfiguration acfg = new AnnotationConfiguration();
//		acfg.setInterceptor(new AnnotatedInterceptor());
        acfg.addProperties(properties);
        acfg.setProperty("hibernate.connection.release_mode", ConnectionReleaseMode.ON_CLOSE.toString());
        for(Class<?> c:annotatedClasses){
        	acfg.addAnnotatedClass(c);
        }
        return acfg.buildSessionFactory();
	}
	
	public String getCountString(String hql){
		//select xx from ... -> select count(xx) from ...
		
		//from ... -> select count(*) from ...
		//TODO: getCountString
		throw new UnsupportedOperationException("get count string not support yet!");
	}
}
